/**
 * 转化文件为JSON
 * @param {*} blob 
 * @returns 
 */
export function transformFileToJSON(blob, fileEncode = 'utf8') {
    const reader = new FileReader()
    reader.readAsText(blob, fileEncode)
    return new Promise(resolve => {
        reader.onload = e => {
            try {
                const result = JSON.parse(e.target.result)
                resolve(result)
            } catch (e) {
                resolve(e.target.result)
            }
        }
    })
}
/**
 * 上传文件
 * @returns 文件列表
 */
export function uploadFile() {
    const input = document.createElement('input')
    input.type = 'file'
    input.click()
    return new Promise(resolve => {
        input.oninput = e => {
            resolve(input.files)
        }
    })
}